package com.leetcode;

/**
 * 824. 山羊拉丁文
 *
 * @author fy
 * @date 2022/4/21 8:55
 */
public class Solution824 {

    public String toGoatLatin(String sentence) {
        String[] senArr = sentence.split(" ");
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < senArr.length; i++) {
            String str = senArr[i];
            char startCh = str.charAt(0);
            if (isAeiou(startCh)) {
                sb.append(str).append("ma");
            } else if (!isAeiou(startCh)) {
                sb.append(str.substring(1)).append(startCh).append("ma");
            }
            for (int j = 0; j < i + 1; j++) {
                sb.append('a');
            }
            if (i != senArr.length - 1) {
                sb.append(' ');
            }
        }
        return sb.toString();
    }

    private boolean isAeiou(char ch) {
        return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'
                || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U';
    }

}
